import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Menu extends JPanel implements ActionListener {
    private JButton backBtn;
    private JButton cun;
    private JButton que;
    private JButton cha;
    private Start frame;
    private Icon anj=Util.getIcon("/images/buttonOff.jpg");
    private Icon anj1=Util.getIcon("/images/buttonSave.jpg");
    private Icon anj2=Util.getIcon("/images/buttonGet.jpg");
    private Icon anj3=Util.getIcon("/images/buttonFind.jpg");

    public Menu(Start frame) {
        this.frame = frame;
        this.setLayout(null);
        this.setOpaque(false);
        JLabel titleLabel = new JLabel("菜单");
        titleLabel.setBounds(380, 10, 100, 50);
        this.add(titleLabel);

        backBtn = new JButton(anj);
        backBtn.setBounds(0, 400, 100, 50);
        this.add(backBtn);
        backBtn.addActionListener(this);

        cun = new JButton(anj1);
        cun.setBounds(0, 300, 100, 50);
        this.add(cun);
        cun.addActionListener(this);

        que = new JButton(anj2);
        que.setBounds(0, 200, 100, 50);
        this.add(que);
        que.addActionListener(this);

        cha = new JButton(anj3);
        cha.setBounds(0, 100, 100, 50);
        this.add(cha);
        cha.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (backBtn == e.getSource()) {
            frame.switchPanel("login");
        }else if (cun == e.getSource()){
            frame.switchPanel("Cun");
        }else if (que == e.getSource()){
            frame.switchPanel("Que");
        }else if (cha == e.getSource()){
            frame.switchPanel("Cha");
        }
    }

}
